#pragma once

// forward declare
class IrrPhysWorld;

class IrrPhysAnimator
{
public:
	irr::scene::ISceneNode *	m_poSceneNode;

	IrrPhysImpulseParams		m_oImpulseParams;
	btRigidBody*				m_poRigidBody;
	btDefaultMotionState*		m_poMotionState;
	btCollisionShape*			m_poCollisionShape;
	IrrPhysWorld *				m_poPhysWorld;
	btDiscreteDynamicsWorld		m_poDynamicsWorld;

	//=== constructor ===//
	IrrPhysAnimator();
	//=== destructor ===//
	virtual ~IrrPhysAnimator();

	//! initialize
	void NodePhysStartup(	IrrPhysWorld *			poPhysWorld,
							irr::scene::ISceneNode* poSceneNode,
							IrrPhysGeomParams	*	poGeomParams,
							IrrPhysImpulseParams *	poImpulseParams );

	//! shutdown
	void NodePhysShutdown( void );

	//! animates a scene node
	void animateNode( irr::scene::ISceneNode* node, irr::u32 timeMs);

	//! Writes attributes of the scene node animator.
	void serializeAttributes(irr::io::IAttributes* out, irr::io::SAttributeReadWriteOptions* options=0);

	//! Reads attributes of the scene node animator.
	void deserializeAttributes(irr::io::IAttributes* in, irr::io::SAttributeReadWriteOptions* options=0);

	//! Returns type of the scene node animator
	irr::scene::ESCENE_NODE_ANIMATOR_TYPE getType() const { return irr::scene::ESNAT_COLLISION_RESPONSE; }

	//! get position
	irr::core::vector3df getPosition() const;
	//! set position
	void setPosition(const irr::core::vector3df& v3fPos = irr::core::vector3df(0,0,0)) const;
	//! get rotation
	irr::core::vector3df getRotation() const;
	//! set rotation
	void setRotation(const irr::core::vector3df& v3fRot = irr::core::vector3df(0,0,0)) const;
	//! get linear velocity
	irr::core::vector3df getLinearVelocity() const;
	//! set linear velocity
	void setLinearVelocity(const irr::core::vector3df& vel = irr::core::vector3df(0,0,0)) const;
	//! get Angular velocity
	irr::core::vector3df getAngularVelocity() const;
	//! set Angular velocity
	void setAngularVelocity(const irr::core::vector3df& vel = irr::core::vector3df(0,0,0)) const;

	void applyImpulse(	const irr::core::vector3df& impulse,
						const irr::core::vector3df& rel_pos = irr::core::vector3df(0,0,0)) const;

	void applyForce(	const irr::core::vector3df& force,
						const irr::core::vector3df& rel_pos = irr::core::vector3df(0,0,0)) const;
	void zeroForces();
	void setActivationState(bool active);
	void activate(bool force = false);
	virtual irr::scene::ISceneNodeAnimator *	createClone(	irr::scene::ISceneNode* node,
																irr::scene::ISceneManager* newManager=0){};

};
